from socket import *
from tkinter import *

host = ""
#菜单
def click():
    global host
    host = hst.get()
    #网络连接
    me = socket(AF_INET,SOCK_STREAM)
    port = 12345
    me.connect((host,port))
    welcome = me.recv(1024)
    print(welcome.decode("utf-8"))
    me.send(str("hello").encode("utf-8"))
    window.destroy()
window = Tk()
lab = Label(window,text="Hostname")
hst = Entry(window)
ok = Button(window,text="OK",command=click)
lab.grid(column=1,row=1)
hst.grid(column=2,row=1)
ok.grid(column=3,row=1)

window.mainloop()



